<template>
  <div class="grand-spin-container">
    <div class="control-panel">
      <div class="config-item">
        <label class="switch">
          <input type="checkbox" v-model="spinConfig.showImg">
          <span class="slider"></span>
        </label>
        <span class="label-text">显示图片</span>
      </div>
      
      <div class="config-item">
        <span class="size-label">转盘大小: {{ spinConfig.size }}px</span>
        <input 
          type="range" 
          min="200" 
          max="1600" 
          step="10"
          v-model.number="spinConfig.size" 
          class="slider-input"
        >
      </div>
    </div>
    
    <div class="wheel-container">
      <spin-panel
        :showImg="spinConfig.showImg"
        :size="spinConfig.size"
        @spin-end="handleEnd"
      />
    </div>
  </div>
</template>

<script>
import SpinPanel from './parts/spin-panel.vue';

export default {
  components: {
    SpinPanel
  },
  data() {
    return {
      spinConfig: {
        showImg: false,
        size: 350
      }
    };
  },
  methods: {
    handleEnd(item) {
      console.log('旋转结果:', item);
      alert(`恭喜获得: ${item.result.label}`);
    }
  }
}
</script>

<style scoped>
.grand-spin-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;
}

.control-panel {
  background-color: white;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.config-item {
  display: flex;
  align-items: center;
}

/* 开关样式 */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #4361ee;
}

input:checked + .slider:before {
  transform: translateX(22px);
}

/* 文本样式 */
.label-text {
  margin-left: 15px;
  font-size: 16px;
  font-weight: 500;
  color: #333;
}

.size-label {
  min-width: 130px;
  font-size: 16px;
  color: #333;
  font-weight: 500;
}

/* 滑块样式 */
.slider-input {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: #e0e0e0;
  outline: none;
  -webkit-appearance: none;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #4361ee;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.slider-input::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #4361ee;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  border: none;
}

.wheel-container {
  background-color: white;
  border-radius: 16px;
  padding: 25px;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.15);
}
</style>